﻿@using System.Data;
@using System.Web;
@using DTcms.Web.MVC.Areas.Web.Controllers;
@using DTcms.Web.MVC.UI.Controllers;
@using DTcms.Model;
@{
   Layout = "~/Areas/Web/Views/" + ViewBag.TemplateSkin + "/Shared/_LayoutList.cshtml";
   DTcms.Model.sites site = ViewData["site"] as DTcms.Model.sites;
   DTcms.Model.sysconfig config = ViewData["sysConfig"] as DTcms.Model.sysconfig;
   Article_ListController bc = ViewBag.BasePage as Article_ListController;
   DTcms.Model.article_category m = ViewData["model"] as DTcms.Model.article_category;
   ViewBag.Title = m.title + " - " + site.name;
   string channel = "news";
   int category_id = int.Parse(ViewBag.CategoryId as string);
   int pagesize = 20;
   int totalcount = 0;
   string pagelist;
   int page = int.Parse(ViewBag.Page as string);
}

<!--当前位置-->
@{string category_nav = bc.get_category_menu("news_list", category_id);}
<div class="section">
  <div class="location">
    <span>当前位置：</span>
    <a href="@bc.linkurl("index")">首页</a> &gt;
        <a href="@bc.linkurl("news")">新闻资讯</a>
    @Html.Raw(category_nav)
  </div>
</div>
<!--/当前位置-->

<div class="section clearfix">
  <!--/页面右边-->
  <div class="right-260">
    <div class="bg-wrap nobg">
      <div class="sidebar-box">
        <h4>资讯类别</h4>
        <ul class="navbar">
          @{DataTable categoryList1 = bc.get_category_child_list(channel, 0);}
          @foreach (DataRow cdr1 in categoryList1.Rows) {
            <li>
              <h5><a href="@bc.linkurl("news_list", cdr1["id"])">@cdr1["title"]</a></h5>
              <p>
                @{DataTable categoryList2 = bc.get_category_child_list(channel, Convert.ToInt32(cdr1["id"]));}
                @foreach (DataRow cdr2 in categoryList2.Rows) {
                  if (Convert.ToInt32(cdr2["id"]) == category_id) {
                  <a href="@bc.linkurl("news_list", cdr2["id"])" class="selected">@cdr2["title"]</a>
                  }
                  else {
                  <a href="@bc.linkurl("news_list", cdr2["id"])">@cdr2["title"]</a>
                  }
                }
              </p>
            </li>
          }
        </ul>
      </div>

      <div class="sidebar-box">
        <h4>图片新闻</h4>
        <ul class="side-img-list">
          @{DataTable redNews = bc.get_article_list(channel, 0, 4, "status=0 and is_red=1 and img_url<>''");}
          @foreach (DataRow dr in redNews.Rows) {
            <li>
              <div class="img-box">
                <img src="@dr["img_url"]" />
              </div>
              <div class="txt-box">
                <a href="@bc.linkurl("news_show", dr["id"])">@dr["title"]</a>
                <span>@DateTime.Parse(dr["add_time"].ToString()).ToString("yyyy-MM-dd")</span>
              </div>
            </li>
          }
        </ul>
      </div>

      <div class="sidebar-box">
        <h4>阅读排行</h4>
        <ul class="txt-list">
          @{DataTable hotNews = bc.get_article_list(channel, 0, 10, "status=0", "click desc,id desc");}
          @for (int i = 0; i < hotNews.Rows.Count; i++) {
            DataRow hotdr = hotNews.Rows[i];
            <li>
              @if (i == 0) {
                <label class="hot">@(i + 1)</label>
              }
              else {
                <label>@(i + 1)</label>
              }
              <a href="@bc.linkurl("news_show", hotdr["id"])">@hotdr["title"]</a>
            </li>
          }
        </ul>
      </div>

    </div>
  </div>
  <!--/页面右边-->

  <!--页面左边-->
  <div class="left-auto">
    <div class="bg-wrap">
      <ul class="n-list">
        <!--取得一个分页DataTable-->
        @{DataTable newsList = bc.get_article_list(channel, category_id, pagesize, page, "status=0", out totalcount, out pagelist, "news_list", category_id, "__id__");}
        @foreach (DataRow dr in newsList.Rows) {
          <li>
            <h2><a href="@bc.linkurl("news_show", dr["id"])">@dr["title"]</a></h2>
            <div class="note">
              @if (dr["img_url"] != "") {
                <b><img src="@dr["img_url"]" /></b>
              }
              <p>@Html.Raw(dr["zhaiyao"])</p>
              <div class="info">
                <span><i class="iconfont icon-date"></i>@dr["add_time"]</span>
                <span><i class="iconfont icon-comment"></i>
                  <script type="text/javascript" src="@(config.webpath)tools/submit_ajax.ashx?action=view_comment_count&channel_id=@dr["channel_id"]&id=@dr["id"]"></script>
                  人评论</span>
                <span><i class="iconfont icon-view"></i>
                  <script type="text/javascript" src="@(config.webpath)tools/submit_ajax.ashx?action=view_article_click&channel_id=@dr["channel_id"]&id=@dr["id"]"></script>
                  次浏览</span>
              </div>
            </div>
          </li>
        }
      </ul>

      <!--页码列表-->
      <div class="page-box">
        <div class="digg">@Html.Raw(pagelist)</div>
      </div>
      <!--/页码列表-->

    </div>
  </div>
  <!--/页面左边-->
</div>
